/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.personal.utils;

public enum BusinessCode {
    SUCCESS(0,"success"),
    FAILURE(-1,"fail"),
    EXCEPTION(-2,"执行过程中发生异常"),
    NOT_LONGIN(-3,"没有登录，无法执行操作"),
    NOT_CHANGE_DATA(1300000,"未选中数据"),
    CERTIFICATE_EMPTY_NAME(1300001,"证照名称不能为空"),
    CERTIFICATE_EMPTY_PERIOD(1300002,"证照有效期不能为空"),
    CERTIFICATE_EMPTY_ATTACHMENT(1300003,"证照扫描件不能为空"),
    CERTIFICATE_NOT_EXIST(1300004,"证照不存在"),
    CERTIFICATE_IS_EXISTED(1300005,"证照已经上传了"),
    CERTIFICATE_EMPTY_DUTY(1300006,"证照所属岗位工种不能为空"),

    GROUP_EMPTY_NAME(140001,"用户群组名称不能为空"),
    GROUP_NAME_EXISIT(140002,"用户群组名称已存在"),
    MESSAGE_EMPTY_PARAMS(140003,"缺少必要参数"),
    GROUP_NOT_EXISIT(140004,"用户群组不存在"),
    ;
    private final int code;
    private final String description;

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    BusinessCode(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public static BusinessCode valueOf(int value){
        switch (value){
            case 0:
                return SUCCESS;
            case -1:
                return FAILURE;
            case -2:
                return EXCEPTION;
            case -3:
                return NOT_LONGIN;
            case 1300000:
                return NOT_CHANGE_DATA;
            case 1300001:
                return CERTIFICATE_EMPTY_NAME;
            case 1300002:
                return CERTIFICATE_EMPTY_PERIOD;
            case 1300003:
                return CERTIFICATE_EMPTY_ATTACHMENT;
            case 1300004:
                return CERTIFICATE_NOT_EXIST;
            case 1300005:
                return CERTIFICATE_IS_EXISTED;
            case 1300006:
                return CERTIFICATE_EMPTY_DUTY;
            default:
                return null;
        }
    }
}
